
const host = "/api"

export function CheckWritingStandards(data: anyObj) {
    // let params = '';
    // for (let k in data) {
    //     if (params) params += '&';
    //     params += `${k}=${data[k]}`;
    // }
    return new Promise((resolve, reject) => {
        uni.uploadFile({
            // url:'http://cceval.uoumei.com/api/upload_image',
            // url: `/api/upload_image?${params}`,
            url: `${host}/upload_image`,
            filePath: data.file,
            name: 'file',
            formData: data,
            header: {
                token: data.token,
                // 'content-type': 'multipart/form-data',
                // 'Channel-Id': data.channel_id,
                // 'symbol-Id': data.symbol_id,
                // 'timestamp':data.timestamp,
                // 'request_id':'123456'
            },
            success: uploadFileRes => {
                console.log('uploadFileRes', uploadFileRes);
                if (uploadFileRes.statusCode !== 200) {
                    reject(uploadFileRes.statusCode);
                }
                const data = JSON.parse(uploadFileRes.data);
                console.log('data', data);
                if (data.code === 200) {
                    resolve(data.data);
                } else {
                    console.log('xxx', data);
                    reject(data);
                }
            },
            fail: error => {
                console.log('error', error);
                uni.hideLoading();
                reject(error);
            },
        });
    });
}
